{{#unless tagserviceactive}}
<section class="tagservice-section">
  <div class="alert alert-danger">{{{t this "tagservice-disabled"}}}</div>
</section>
{{/unless}}

<section class="tagservice-section">
  <header class="tagservice-section-header">
    <h3>{{{t this "tagcollections"}}}</h3>
    <div class="btn-toolbar float-end">
        {{#if canCreate}}
            <a href="{{{newURL this 'tagcollections' 'new'}}}" class="btn btn-primary btn-sm pull-right">{{{t this "Create Tag Collection"}}}</a>
        {{/if}}
    </div>
  </header>

  {{#if canCreate}}
    <table class="tagservice-table table table-striped table-hover table-condensed">
      <thead>
        <tr>
          <th class="tags-collections-percent-small">{{{t this "name"}}}</th>
          <th class="tags-collections-percent-big">{{{t this "description"}}}</th>
          <th class="tags-collections-percent-small">{{{t this "externalSourceName"}}}</th>
          <th class="tags-collections-percent-big">{{{t this "externalSourceDescription"}}}</th>
          <th><!-- actions --></th>
        </tr>
      </thead>
      <tbody>
        {{#if tagcollections.length}}
          {{#each tagcollections}}
          <tr>
            <td>{{this.name}}</td>
            <td>{{this.description}}</td>
            <td>{{this.externalSourceName}}</td>
            <td>{{this.externalSourceDescription}}</td>
            <td class="actions">
              <a href="{{{actionURL this 'tagcollections' this.tagCollectionId "edit"}}}" class="btn btn-primary btn-xs">{{{t this "Edit"}}}</a>           
              <a href="{{{actionURL this 'tagsintagcollection' this.tagCollectionId "manage"}}}" class="btn btn-primary btn-xs">{{{t this "Manage Tags"}}}</a>
              <a href="{{{actionURL this 'tagcollections' this.tagCollectionId "delete"}}}" class="btn btn-warning btn-xs tagservice-delete-btn" data-record-type="tagcollection" aria-label="{{{t this "Delete Tag Collection"}}}" title="{{{t this "Delete Tag Collection"}}}"><span class="fa fa-trash" aria-hidden="true"></span></a>
            </td>
          </tr>
          {{/each}}
        {{else}}
          <tr>
            <td colspan="5" class="text-center">
              <div class="alert alert-info" style="margin-top: 15px;">
                {{{t this "no_tags_in_collection"}}}
              </div>
            </td>
          </tr>
        {{/if}}
      </tbody>
    </table>
  {{else}}
    <table class="tagservice-table table table-striped table-hover table-condensed">
      <thead>
        <tr>
          <th class="tags-collections-percent-small">{{{t this "name"}}}</th>
          <th class="tags-collections-percent-big">{{{t this "description"}}}</th>
          <th class="tags-collections-percent-small">{{{t this "externalSourceName"}}}</th>
          <th class="tags-collections-percent-big">{{{t this "externalSourceDescription"}}}</th>
          <th><!-- actions --></th>
        </tr>
      </thead>
      <tbody>
        {{#if tagcollections.length}}
          {{#each tagcollections}}
          <tr>
            <td>{{this.name}}</td>
            <td>{{this.description}}</td>
            <td>{{this.externalSourceName}}</td>
            <td>{{this.externalSourceDescription}}</td>
            <td class="actions">          
              <a href="{{{actionURL this 'tagsintagcollection' this.tagCollectionId "manage"}}}" class="btn btn-primary btn-xs">{{{t this "Manage Tags"}}}</a>
            </td>
          </tr>
          {{/each}}
        {{else}}
          <tr>
            <td colspan="5" class="text-center">
              <div class="alert alert-info" style="margin-top: 15px;">
                {{{t this "no_tags_in_collection"}}}
              </div>
            </td>
          </tr>
        {{/if}}
      </tbody>
    </table>
  {{/if}}

    <!--pagination param ==> kkkkk currentPage:{{pageNum}} totalPageCount:{{totalPages}} countPerPageGroup:{{countPerPageGroup}}-->
    {{#if showPagination}}
        {{#pagination this pageNum totalPages countPerPageGroup}}
            <div class="paging_bootstrap">
                <ul class="pagination">
                    {{#if canGoPrevious}}
                        <li class="page-item prev"><a class="page-link" href="{{actionURLPaginated this 'index' "0" "manage" previousIdx pageSize}}"><i class="icon-double-angle-left">&Lt;</i></a></li>
                    {{else}}
                        <li class="page-item prev disabled"><a class="page-link" href="#"><i class="icon-double-angle-left">&Lt;</i></a></li>
                    {{/if}}

                    {{#each pages}}
                        <li {{#if isCurrent}}class="page-item active"{{/if}}><a class="page-link" href="{{actionURLPaginated this 'index' "0" "manage" pageInt pageSize}}">{{page}}</a></li>
                    {{/each}}

                    {{#if canGoNext}}
                        <li class="page-item next"><a class="page-link" href="{{actionURLPaginated this 'index' "0" "manage" nextIdx pageSize}}"><i class="icon-double-angle-right">&Gt;</i></a></li>
                    {{else}}
                        <li class="page-item next disabled"><a class="page-link" href="#"><i class="icon-double-angle-right">&Gt;</i></a></li>
                    {{/if}}
                </ul>
            </div>
        {{/pagination}}
    {{/if}}


</section>

<script id="tagserviceDeleteConfirmationModalTemplate" type="text/template">
  <div class="tag-modal modal fade" id="tagserviceDeleteConfirmationModal">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="{{{t this "Close"}}}"><span aria-hidden="true">&times;</span></button>
          <h4 class="modal-title">
            {if recordType == "tagcollection"}
              {{{t this "Delete Tag Collection"}}}
            {/if}
          </h4>
        </div>
        <div class="modal-body">
          <p>
            {if recordType == "tagcollection"}
              {{{t this "Are you sure you want to delete this tag collection?"}}}
            {/if}
          </p>
        </div>
        <div class="modal-footer">
          <form action="${deleteURL}" method="POST">
            <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">{{{t this "Close"}}}</button>
            <button type="submit" class="btn btn-danger btn-sm">
              {if recordType == "tagcollection"}
                {{{t this "Delete Tag Collection"}}}
              {/if}
            </button>
          </form>
        </div>
      </div>
    </div>
  </div>
</script>
